function requestPost(url, params, message, success, fail) {
    this.requestLoading(url, 'POST', params, message, success, fail)
}
function requestGet(url, params, message, success, fail) {
    this.requestLoading(url, 'GET', params, message, success, fail)
}
// 展示进度条的网络请求
// url:网络请求的url
// params:请求参数
// message:进度条的提示信息
// success:成功的回调函数
// fail：失败的回调
function requestLoading(url, method, params, message, success, fail) {
    console.log(url,params)
    wx.showNavigationBarLoading();
    if (message != "") {
        wx.showLoading({
            title: message,
            mask: true
        })
    }
    wx.request({
        url: url,
        data: params,
        header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8',},
        method: method,
        success: function (res) {
        console.log(res.data)
        wx.hideNavigationBarLoading()
        if (message != "") {
            wx.hideLoading()
        }
        if (res.statusCode == 200) {
            success(res.data)
        } else {
            fail(res.data)
        }

        },
        fail: function (res) {
            console.log(res)
        wx.hideNavigationBarLoading()
        if (message != "") {
            wx.hideLoading()
        }
        fail(res)
        },
        complete: function (res) {

        },
    })
}
module.exports = {
    requestPost: requestPost,
    requestGet: requestGet,
    requestLoading: requestLoading
}